import request from "@/request/request";
import requestMock from "@/request/requestMock";

// 一级列表
export const reqCategoryList1 = () => {
  return request.get("/admin/product/getCategory1");
};
// 二级列表
export const reqCategoryList2 = (category1Id) => {
  return request.get(`/admin/product/getCategory2/${category1Id}`);
};
// 三级列表
export const reqCategoryList3 = (category2Id) => {
  return request.get(`/admin/product/getCategory3/${category2Id}`);
};

//4. 请求mock的banner数据
export const reqBannerList = () => {
  return requestMock.get(`/mock-api/banner`);
};

//5. 请求mock的floor数据
export const reqFloorList = () => {
  return requestMock.get(`/mock-api/floor`);
};


// 6 请求搜索页数据
export const reqSearchList = (searchParams) => {
  return request.post(`/api/list`, searchParams);
};

// 7请求详情页数据
export const reqDetail = (skuId) => {
  return request.get(`/api/item/${skuId}`,);
};

// 8.添加购物车或者修改购物车数量
export const reqAddOrUpdateCart = (skuId, skuNum) => {
  return request.post(`/api/cart/addToCart/${skuId}/${skuNum}`,);
};

// 9.请求购物车列表
export const reqCartList = () => {
  return request.get(`/api/cart/cartList`,);
};

// 10.修改商品的状态
export const reqGoodChecked = (skuID, isChecked) => {
  return request.get(`/api/cart/checkCart/${skuID}/${isChecked}`);
};

// 11.修改全部商品的状态
export const reqAllGoodChecked = (isChecked, skuIdList) => {
  return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};

// 12.删除
export const reqGoodDelete = (skuId) => {
  return request.delete(`/api/cart/deleteCart/${skuId}`);
};

// 13删除全部
export const reqAllGoodDelete = (skuIdList) => {
  return request.post(`/api/cart/batchDeleteCart`, skuIdList);
};


// 14. 获取验证码 
export const reqPhoneCode = (phone) => {
  return request.get(`/api/user/passport/sendCode/${phone}`);
};

// 15.注册
export const reqRegister = (userInfo) => {
  return request.post(`/api/user/passport/register`, userInfo);
};


// 16.登录
export const reqLogin = (userInfo) => {
  return request.post(`/api/user/passport/login`, userInfo);
};

// 17.获取用户信息
export const requserMessage = () => {
  return request.get(`/api/user/passport/auth/getUserInfo`);
};

// 18.退出登录
export const reqLogout = () => {
  return request.get(`/api/user/passport/logout`);
};

// 19获取交易页信息
export const reqTradeInfo = () => {
  return request.get(`/api/order/auth/trade`);
};

//20. 获取当前的收获地址
export const reqAddress = () => {
  return requestMock.get(`/mock-api/address`);
};

// 21.提交订单
export const reqAddOrde = (tradeNo, tradeInfo) => {
  return request.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`, tradeInfo);
};

// 22.订单信息
export const reqOrdeMessage = (orderId) => {
  return request.get(`/api/payment/weixin/createNative/${orderId}`);
};

// 23. 查询支付状态
export const reqPayMessage = (orderId) => {
  return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`);
};

// 24. 获取我的订单列表
export const reqMyOrder = (page, limit) => {
  return request.get(`/api/order/auth/${page}/${limit}`);
};